home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / pmdev / e / demos / layout.e < prev    next >
Encoding:
Text File  |  2000-02-28  |  7.9 KB  |  228 lines

  1. /* -- ----------------------------------------------------------------- -- *
  2.  * -- Program.....: Layout.e                                            -- *
  3.  * -- Author......: Daniel Kasmeroglu <raptor@cs.tu-berlin.de>          -- *
  4.  * -- Description.: Port of an example by Henrik Isaksson               -- *
  5.  * -- ----------------------------------------------------------------- -- *
  6.  * -- Original header:                                                  -- *
  7.  * --                                                                   -- *
  8.  * -- $VER: Layout.c 1.0 (16.07.99)                                     -- *
  9.  * --                                                                   -- *
  10.  * -- Popup Menu example program                                        -- *
  11.  * --                                                                   -- *
  12.  * -- ©1996-1998 Henrik Isaksson                                        -- *
  13.  * -- All Rights Reserved.                                              -- *
  14.  * --                                                                   -- *
  15.  * -- ----------------------------------------------------------------- -- */
  16.  
  17. /* -- ----------------------------------------------------------------- -- *
  18.  * --                              Options                              -- *
  19.  * -- ----------------------------------------------------------------- -- */
  20.  
  21. OPT PREPROCESS       -> enable preprocessor
  22.  
  23.  
  24. /* -- ----------------------------------------------------------------- -- *
  25.  * --                              Modules                              -- *
  26.  * -- ----------------------------------------------------------------- -- */
  27.  
  28. MODULE 'libraries/popupmenu' ,
  29.        'intuition/intuition' ,
  30.        'utility/tagitem'     ,
  31.        'utility/hooks'       ,
  32.        'tools/inithook'      
  33.  
  34. MODULE 'popupmenu'
  35.  
  36.  
  37. /* -- ----------------------------------------------------------------- -- *
  38.  * --                               Main                                -- *
  39.  * -- ----------------------------------------------------------------- -- */
  40.  
  41. ->»» PROC main
  42. PROC main()
  43. DEF ma_window    : PTR TO window
  44. DEF ma_menu      : PTR TO popupmenu
  45. DEF ma_imsg1     : PTR TO intuimessage
  46. DEF ma_imsg2     : intuimessage
  47. DEF ma_result
  48.  
  49.   ma_result     := TRUE
  50.  
  51.   popupmenubase := OpenLibrary( 'popupmenu.library', 9 )
  52.   IF popupmenubase <> NIL
  53.  
  54.     -> Declared at the end of this file.
  55.     ma_menu := glo_MakeTestMenu()
  56.     IF ma_menu <> NIL
  57.  
  58.       -> Open a little window
  59.       ma_window := OpenWindowTagList( NIL,
  60.       [ WA_IDCMP       , IDCMP_CLOSEWINDOW OR IDCMP_MOUSEBUTTONS OR IDCMP_VANILLAKEY ,
  61.         WA_RMBTRAP     , TRUE            ,
  62.         WA_DRAGBAR     , TRUE            ,
  63.         WA_WIDTH       , 150             ,
  64.         WA_HEIGHT      , 100             ,
  65.         WA_LEFT        , 0               ,
  66.         WA_TOP         , 100             ,
  67.         WA_TITLE       , 'Layout' ,
  68.         WA_CLOSEGADGET , TRUE            ,
  69.         TAG_END ] )
  70.  
  71.       IF ma_window <> NIL
  72.  
  73.         WHILE ma_result <> FALSE
  74.  
  75.           -> Wait for a message
  76.           WaitPort( ma_window.userport )
  77.  
  78.           -> Get the message
  79.           WHILE (ma_imsg1 := GetMsg( ma_window.userport )) <> NIL
  80.  
  81.             -> Copy the contents of it
  82.             CopyMem( ma_imsg1, ma_imsg2, SIZEOF intuimessage )
  83.  
  84.             -> Reply the message
  85.             ReplyMsg( ma_imsg1 )
  86.  
  87.             IF ma_imsg2.class = IDCMP_MOUSEBUTTONS
  88.               Pm_OpenPopupMenuA( ma_window, [ PM_MENU, ma_menu, TAG_END ] )
  89.             ELSEIF ma_imsg2.class = IDCMP_CLOSEWINDOW
  90.               -> See if the user wants to quit
  91.               ma_result := FALSE
  92.             ENDIF
  93.  
  94.           ENDWHILE
  95.  
  96.         ENDWHILE
  97.  
  98.         CloseWindow( ma_window )
  99.  
  100.       ELSE
  101.         PrintF( 'Window error !\n' )
  102.       ENDIF
  103.       Pm_FreePopupMenu( ma_menu )
  104.     ELSE
  105.       PrintF( 'Menu error !\n' )
  106.     ENDIF
  107.  
  108.     CloseLibrary( popupmenubase )
  109.  
  110.   ELSE
  111.     PrintF( 'Cannot open "popupmenu.library" v9+ !\n' )
  112.   ENDIF
  113.  
  114. ENDPROC
  115. ->»»>
  116.  
  117.  
  118. /* -- ----------------------------------------------------------------- -- *
  119.  * --                             Functions                             -- *
  120.  * -- ----------------------------------------------------------------- -- */
  121.  
  122. ->»» PROC glo_MakeTestMenu
  123. PROC glo_MakeTestMenu()
  124. DEF mak_menu : PTR TO popupmenu
  125.  
  126.   mak_menu := PMMenu( 'Group Layout' ),
  127.               PMHoriz,
  128.                 PMMembers,
  129.                   PMItem( 'Left' ), 
  130.                     PM_CENTER, TRUE, 
  131.                   PMEnd,
  132.                   PMVert,
  133.                     PMMembers,
  134.                       PMItem( 'Item 1' ), PM_CENTER, TRUE, PMEnd,
  135.                       PMItem( 'Item 2' ), PM_CENTER, TRUE, PMEnd,
  136.                       PMItem( 'Item 3' ), PM_CENTER, TRUE, PMEnd,
  137.                       PMItem( 'Item 4' ), PM_CENTER, TRUE, PMEnd,
  138.                       PMItem( 'Item 5' ), PM_CENTER, TRUE, PMEnd,
  139.                       PMItem( 'Item 6' ), PM_CENTER, TRUE, PMEnd,
  140.                     PMEnd,
  141.                   PMEnd,
  142.                   PMItem( 'Right' ), 
  143.                     PM_CENTER, TRUE, 
  144.                   PMEnd,
  145.                 PMEnd,
  146.               PMEnd,
  147.               PMBar, PMEnd,
  148.               PMVert,
  149.                 PMMembers,
  150.                   PMHoriz,
  151.                     PMMembers,
  152.                       PMColBox(1), PMEnd,
  153.                       PMColBox(2), PMEnd,
  154.                       PMColBox(3), PMEnd,
  155.                       PMColBox(4), PMEnd,
  156.                       PMColBox(5), PMEnd,
  157.                       PMColBox(6), PMEnd,
  158.                       PMColBox(7), PMEnd,
  159.                       PMColBox(8), PMEnd,
  160.                       PMColBox(9), PMEnd,
  161.                       PMColBox(0), PMEnd,
  162.                     PMEnd,
  163.                   PMEnd,
  164.                   PMHoriz,
  165.                     PMMembers,
  166.                       PMColBox(11), PMEnd,
  167.                       PMColBox(12), PMEnd,
  168.                       PMColBox(13), PMEnd,                    
  169.                       PMColBox(14), PMEnd,
  170.                       PMColBox(15), PMEnd,
  171.                       PMColBox(16), PMEnd,
  172.                       PMColBox(17), PMEnd,
  173.                       PMColBox(18), PMEnd,
  174.                       PMColBox(19), PMEnd,
  175.                       PMColBox(10), PMEnd,
  176.                     PMEnd,
  177.                   PMEnd,
  178.                   PMHoriz,
  179.                     PMMembers,
  180.                       PMColBox(21), PMEnd,
  181.                       PMColBox(22), PMEnd,
  182.                       PMColBox(23), PMEnd,
  183.                       PMColBox(24), PMEnd,
  184.                       PMColBox(25), PMEnd,
  185.                       PMColBox(26), PMEnd,
  186.                       PMColBox(27), PMEnd,
  187.                       PMColBox(28), PMEnd,
  188.                       PMColBox(29), PMEnd,
  189.                       PMColBox(20), PMEnd,
  190.                     PMEnd,
  191.                   PMEnd,
  192.                   PMHoriz,
  193.                     PMMembers,
  194.                       PMColBox(31), PMEnd,
  195.                       PMColBox(32), PMEnd,
  196.                       PMColBox(33), PMEnd,
  197.                       PMColBox(34), PMEnd,
  198.                       PMColBox(35), PMEnd,
  199.                       PMColBox(36), PMEnd,
  200.                       PMColBox(37), PMEnd,
  201.                       PMColBox(38), PMEnd,
  202.                       PMColBox(39), PMEnd,
  203.                       PMColBox(30), PMEnd,
  204.                     PMEnd,
  205.                   PMEnd,
  206.                   PMHoriz,
  207.                     PMMembers,
  208.                       PMColBox(41), PMEnd,
  209.                       PMColBox(42), PMEnd,
  210.                       PMColBox(43), PMEnd,
  211.                       PMColBox(44), PMEnd,
  212.                       PMColBox(45), PMEnd,
  213.                       PMColBox(46), PMEnd,
  214.                       PMColBox(47), PMEnd,
  215.                       PMColBox(48), PMEnd,
  216.                       PMColBox(49), PMEnd,
  217.                       PMColBox(40), PMEnd,
  218.                     PMEnd,
  219.                   PMEnd,
  220.                 PMEnd,
  221.               PMEnd,
  222.               PMBar, PMEnd,
  223.               PMItem( 'Quit' ), PMEnd,
  224.         PMEnd
  225.     
  226. ENDPROC mak_menu
  227. ->»»>
  228.